package com.atguigu.juc.future;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Description: FutureTask 初识
 * @author： yeswater
 * @create： 2024/5/28
 */

public class FutureTaskDemo {
	public static void main(String[] args) throws ExecutionException, InterruptedException {
		FutureTask<String> futureTask = new FutureTask<>(new MyThread());
		
		Thread t1 = new Thread(futureTask, "t1");
		t1.start();
		
		System.out.println("---- 返回值: " + futureTask.get());
	}
	
	static class MyThread implements Callable<String> {
		
		@Override
		public String call() throws Exception {
			System.out.println("---- come in call");
			return "hello callable";
		}
	}
}
